<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    // var moveZeroes = function(nums) {
    //     if(nums.length === 1) return nums;
    //     let left = 0 , right = 0;
    //     for(left; left < nums.length; left++) {
    //
    //     }
    //     return nums;
    // };

    // console.log(moveZeroes([0,1,0,3,12]))


    var moveZeroes = function(nums) {
        if(nums.length === 1) return nums;
        let left = 0 , right = 0;
        while(right < nums.length) {
            if(nums[right] !== 0) {
                [ nums[left] , nums[right] ] = [ nums[right] , nums[left] ];
                left++;
            }
            right++;
        }
        return nums;
    }

    console.log(moveZeroes([0,1,0,3,12]))
</script>
</body>
</html>
